package merchant

import (
	"context"
	"fmt"
	"go-zero-mult/service/api/internal/svc"
	"go-zero-mult/service/api/internal/types"
	"go-zero-mult/service/rpc/merchant/merchant"

	"github.com/tal-tech/go-zero/core/logx"
)

type MerchantRegisterLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewMerchantRegisterLogic(ctx context.Context, svcCtx *svc.ServiceContext) MerchantRegisterLogic {
	return MerchantRegisterLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *MerchantRegisterLogic) MerchantRegister(req types.RegisterReq) (*types.RegisterResp, error) {
	// todo: add your logic here and delete this line
	merchantInfo, err := l.svcCtx.MerchantRpc.MerchantRegister(l.ctx,&merchant.MerchantReq{
		Username: req.Username,
	})
	fmt.Println(merchantInfo)
	if err != nil {
		return nil, err
	}
	return &types.RegisterResp{
		Msg: fmt.Sprintf("用户名称:%s,ID:%d注册成功\n",merchantInfo.Username,merchantInfo.Id),
	}, nil


	//return &types.RegisterResp{}, nil
}
